package com.apress.prospring5.ch6;

import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.SqlUpdate;

import javax.sql.DataSource;
import java.sql.Types;

public class InsertSinger extends SqlUpdate {
    private static final String SQL_INSERT_STRING=
            "insert into SINGER (first_name,last_name,birth_date) values(:first_name,:last_name,:birth_date)";

    public InsertSinger(DataSource dataSource) {
        super(dataSource,SQL_INSERT_STRING);
        super.declareParameter(new SqlParameter("first_name", Types.VARCHAR));
        super.declareParameter(new SqlParameter("last_name",Types.VARCHAR));
        super.declareParameter(new SqlParameter("birth_date",Types.DATE));
        super.setGeneratedKeysColumnNames(new String[]{"id"});
        super.setReturnGeneratedKeys(true);

    }
}
